package com.Iconcat.system.mapper;

import com.Iconcat.system.entity.RechargeRecord;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.lettuce.core.dynamic.annotation.Param;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Map;


public interface RechargeRecordMapper  extends BaseMapper<RechargeRecord> {
    @Select("SELECT r.*, u.userid AS user_userid,u.user_name,u.phone_number FROM recharge_record r JOIN cat_user u ON r.userid = u.userid ${ew.customSqlSegment} ORDER BY r.recharge_time DESC")
    IPage<Map<String, Object>> getOrderListPage(Page<?> page,@Param(Constants.WRAPPER) LambdaQueryWrapper<RechargeRecord> ew);

    @Update("UPDATE recharge_record SET status = #{status} WHERE record_id = #{recordId} and userid = #{userid}")
    int updateRecordId(RechargeRecord entity);
    @Delete("DELETE FROM recharge_record WHERE record_id = #{id}")
    int deleteById(Long id);
}
